package com.ruoyi.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkBillStaffsMapper;
import com.ruoyi.work.domain.WorkBillStaffs;
import com.ruoyi.work.service.IWorkBillStaffsService;

/**
 * 工单员工（多个员工共享计件）Service业务层处理
 * 
 * @author xwj
 * @date 2024-08-29
 */
@Service
public class WorkBillStaffsServiceImpl extends ServiceImpl<WorkBillStaffsMapper, WorkBillStaffs> implements IWorkBillStaffsService {
    @Autowired
    private WorkBillStaffsMapper workBillStaffsMapper;

    /**
     * 查询工单员工（多个员工共享计件）
     * 
     * @param id 工单员工（多个员工共享计件）主键
     * @return 工单员工（多个员工共享计件）
     */
    @Override
    public WorkBillStaffs selectWorkBillStaffsById(Long id) {
        return workBillStaffsMapper.selectWorkBillStaffsById(id);
    }

    /**
     * 查询工单员工（多个员工共享计件）列表
     * 
     * @param workBillStaffs 工单员工（多个员工共享计件）
     * @return 工单员工（多个员工共享计件）
     */
    @Override
    public List<WorkBillStaffs> selectWorkBillStaffsList(WorkBillStaffs workBillStaffs) {
        return workBillStaffsMapper.selectWorkBillStaffsList(workBillStaffs);
    }

    /**
     * 新增工单员工（多个员工共享计件）
     * 
     * @param workBillStaffs 工单员工（多个员工共享计件）
     * @return 结果
     */
    @Override
    public WorkBillStaffs insertWorkBillStaffs(WorkBillStaffs workBillStaffs) {

      //  workBillStaffsMapper.insertWorkBillStaffs(workBillStaffs);
    save(workBillStaffs);
    return workBillStaffs;
    }

    /**
     * 修改工单员工（多个员工共享计件）
     * 
     * @param workBillStaffs 工单员工（多个员工共享计件）
     * @return 结果
     */
    @Override
    public WorkBillStaffs updateWorkBillStaffs(WorkBillStaffs workBillStaffs) {

      //  workBillStaffsMapper.updateWorkBillStaffs(workBillStaffs);
        updateById(workBillStaffs);
        return workBillStaffs;
    }

    /**
     * 批量删除工单员工（多个员工共享计件）
     * 
     * @param ids 需要删除的工单员工（多个员工共享计件）主键
     * @return 结果
     */
    @Override
    public int deleteWorkBillStaffsByIds(Long[] ids) {
        return workBillStaffsMapper.deleteWorkBillStaffsByIds(ids);
    }

    /**
    * 条件删除
    * @param workBillStaffs 工单员工（多个员工共享计件）
    * @return
    */
    @Override
    public int delete(WorkBillStaffs workBillStaffs) {
        QueryWrapper<WorkBillStaffs> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workBillStaffs);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param workBillStaffs 工单员工（多个员工共享计件）
     * @return
     */
    @Override
    public Pages<WorkBillStaffs> queryPage(WorkBillStaffs workBillStaffs) {
        QueryWrapper<WorkBillStaffs> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workBillStaffs);
        IPage<WorkBillStaffs> ipage = new Query<WorkBillStaffs>().getPage(workBillStaffs);

        IPage<WorkBillStaffs> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    @Override
    public void deleteWorkBillStaffsByBillId(Long billId) {
        workBillStaffsMapper.deleteWorkBillStaffsByBillId(billId);
    }

    /**
     * 删除工单员工（多个员工共享计件）信息
     * 
     * @param id 工单员工（多个员工共享计件）主键
     * @return 结果
     */
    @Override
    public int deleteWorkBillStaffsById(Long id) {
        return workBillStaffsMapper.deleteWorkBillStaffsById(id);
    }
}
